﻿using Microsoft.SPOT;
using Seditious.NETMF.MuDB;
using VikingErik.NetMF.MicroLinq;
using System;
using MuDBApp.Models;

namespace MuDBApp
{
    public class Program
    {
        public static void Main()
        {
            Program p = new Program();
            p.TestMain();
        }

        public void TestMain()
        {
            // Create new database
            Database db = new Database();
            
            var Products = db.Insert(typeof(Product));
            var Customers = db.Insert(typeof(Customer));

            Products.Insert(new Product(1, "Apple", 1.50f));
            Products.Insert(new Product(2, "Orange", 1.75f));
            Products.Insert(new Product(3, "Banana", 1.30f));

            Customers.Insert(new Customer(1, "Mike", "Jones"));
            Customers.Insert(new Customer(2, "Joe", "Bloggs"));
            Customers.Insert(new Customer(3, "Judy", "Grey"));
            Customers.Insert(new Customer(4, "Mike", "Fresno"));

            foreach (Customer customer in Customers.Data.Where(c => ((Customer)c).Firstname == "Mike"))
            {
                Debug.Print(customer.ToString());
            }

            var product = Products.Data.FirstOrDefault(p => ((Product)p).Name == "Apple");
            Debug.Print(product.ToString());

            
        }
    }
}
